<include file="Public/head" />
<style type="text/css">
    .tanShang .daiJingW{padding: 20px 0 0 10px;}
    .tanShang6 .cardealer-zhanghao{width:560px;}
    .tanShang6{height:260px;}
    .tanShang6 .cardealer-zhanghao{height:30px; line-height:30px;margin:0; text-align:left; overflow:hidden;}
    .tanShang6 .cardealer-zhanghao span{width:90px; text-align:right;float:left; display:block;}
    .tanShang6 .cardealer-zhanghao em{color:#20ab4f;padding:0;font-size:14px;}
    .chexing{z-index:0;}
    #add_fm .tanShang6 li h1{font-size:24px;color:#f7f7f;}
    #add_fm .tanShang6 li h1 b{font-weight: normal;}
    #add_fm .tanShang6 li #qd_re_auction{margin-left:75px;}
</style>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu="yxhd.tjhd"  />
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li onclick="get_list(0)" class="yuCurrent">进行中</li>
                <li onclick="get_list(1)">已结束</li>
            </ul>
        </div>


        <div class="liupai clearfix">
            <script src="http://img2.isou365.cn/paimai/cheshan/js/model_select.js" type="text/javascript"></script>
            <div class="liupai-hao">
                <input type="text" name="car_no" placeholder="请输入车源编号" />
                <input type="text" name="phone" placeholder="请输入车主手机号" />
                <select name="come_from">
                    <option value="">全部渠道</option>
                    <volist name="come_from" id="from">
                        <option value="{$from.from_id}">{$from.from_name}</option>
                    </volist>
                </select>

                <input type="button" value="搜索" class="liupai-btn search"  />
                <input type="button" value="活动设置" class="liupai-btn"  />
                <input type="hidden" name="status" value="0" />
            </div>
        </div>


        <div class="listBox" id="listBox"></div>



         <!--活动设置-->
            <div class="yunBei" style="display:none"></div>
            <form id="add_fm">
                <div class="tanShang tanShang6" style="display:none">
                    <h3>活动设置</h3>
                    <ul class="daiJingW">
                        <li class="clearfix">
                            <span style="width:90px; text-align:right;float:left;margin-left:20px;">累计上限：</span>
                            <input type="text" name="reserve_price" placeholder="请输入累计上限"/>
                            <em>元</em>
                        </li>
                        <li class="clearfix">
                            <span style="width:90px; text-align:right;float:left;margin-left:20px;">抬价区间：</span>
                            <input type="text" name="reserve_price" placeholder="请输入区间低值"/>
                            至
                            <input type="text" name="reserve_price" placeholder="请输入区间高值"/>
                            <em>元</em>
                        </li>
                        <li class="clearfix">
                            <input type="hidden" name="order_id">
                            <input type="hidden" name="owner_id">
                            <input type="button" value="确定" class="queding" id="qd_set"/>
                            <input type="button" value="取消" class="quxiao" />          
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script type="text/javascript">
    get_list(0);
    function get_list(status) {
        $("input[name='status']").val(status);
        var url = mkurl();
        $.get("/Bargain/get_list?status=" + status,url, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function get_page(p) {
        var url = mkurl();
        $.get("/Bargain/get_list?status=" + $('input[name=status]').val() + "&" + encodeURI("p=" + p), url, function (data) {
            $("#listBox").html(data);
        }, "html");
    }
    function bargain_switch(car_id){
        $.get("/Bargain/bargain_switch",{'type':1,'car_id':car_id}, function (data) {
            if(data.code=='200'){
                btn_alert(data.msg,1000,function(){get_list(0)})
            }else{
                shibai_alert(data.msg)
            }
        }, "json");
    }

    /**
     * 监听搜索按钮
     */
    $(".search").on("click",function(){
       var status = $("input[name='status']").val();
       get_list(status); 
    });
    //搜索条件生成
    function mkurl() {
        var url = "";
        var car_no = $("input[name='car_no']").val();
        var brand_id = $('.pingXiaCo').attr('brand_id');
        var series_id = $('.cheXiaCo').attr('series_id');
        var model_id = $('.cheXiaCo1').attr('model_id');
        //
        var phone = $("input[name='phone']").val();
        var come_from = $("select[name='come_from']").val();

        if(car_no){
            url += '&car_no=' + car_no;
        }
        if (brand_id) {
            url += '&brand_id=' + brand_id;
        }
        if (series_id) {
            url += '&series_id=' + series_id;
        }
        if (model_id) {
            url += '&model_id=' + model_id;
        }
        if (phone) {
            url += '&phone=' + phone;
        }
        if (come_from) {
            url += '&come_from=' + come_from;
        }
        return url;
    }
    /**
     * 设置触发监听
     * @param {type} order_id
     * @returns {undefined}确定重拍
     */
    $("#qd_set").on('click',function(){
        order_id = $("input[name='order_id']").val();
        owner_id = $("input[name='owner_id']").val();
        reserve_price = $("input[name='reserve_price']").val();
        params = {
            'order_id':order_id,
            'owner_id':owner_id,
            'reserve_price':reserve_price
        }
        $.post("/Bargain/set_bargain", params, function (data) {
            if (data.code == '200') {
                btn_alert(data.msg, 2000, function () {
                    window.location.reload()
                });
            } else {
                shibai_alert(data.msg);
            }
        }, "json");
    });
    /**
     * 活动设置页面展示
     */
    function show_set_bargain(order_id,owner_id){
        $.post("/Bargain/set_bargain", {'order_id':order_id}, function (data) {
            if(data.code == '200'){
                $("input[name='reserve_price']").val(data.result);
                $("input[name='order_id']").val(order_id);
                $("input[name='owner_id']").val(owner_id);
                $('.yunBei,.tanShang').show();
            }else{
                shibai_alert(data.msg);
            }
        }, "json");
    }
    ///活动设置页面提交处理
    function set_bargain2(order_id) {

        confirm_alert('<div style="color:red">您确定此重拍？</div>', confirm);
        function confirm() {
            $('.determine').click(function () {
                colse_hide();
                do_set_bargain();
            });
        }
        function do_set_bargain() {
            var param = {'order_id': order_id};
            $.post("/Bargain/set_bargain", param, function (data) {
                if (data.code == '200') {
                    btn_alert(data.msg, 2000, function () {
                        window.location.reload()
                    });
                } else {
                    shibai_alert(data.msg);
                }
            }, "json");
        }
    }
</script>
<include file="Public/foot" />